package l2

import "sync"

type VSwitchType struct {
	TypeName string
	Exposed  bool
}

var (
	_lockVSwitchType = sync.RWMutex{}
	typesVSwitch     = map[string]*VSwitchType{}
)

func HasTypeVSwitch(typeName string) bool {
	_lockVSwitchType.RLock()
	_, ok := typesVSwitch[typeName]
	_lockVSwitchType.RUnlock()
	return ok
}

func NewVSwitchType(typeName string, exposed bool) *VSwitchType {
	t := &VSwitchType{
		TypeName: typeName,
		Exposed:  exposed,
	}

	_lockVSwitchType.Lock()
	typesVSwitch[t.TypeName] = t
	_lockVSwitchType.Unlock()

	return t
}

func (t *VSwitchType) String() string {
	return t.TypeName
}
